<div class="page-search-bar">
	<div class="widget-header">
		<div class="align-left">

		</div>
	</div>
</div>

<div class="row">
	<div class="col-xs-12 col-md-12">

		<div class="widget">

			<div class="widget-header bordered-bottom bordered-themeprimary">
				<i class="widget-icon fa fa-tasks themeprimary"></i>
				<span class="widget-caption themeprimary">列表</span>
				<div class="widget-buttons buttons-bordered">
					<%= button_to '新建',new_dict_path , method: :get, :class => "btn btn-blue btn-xs" %>
				</div>

			</div><!--Widget Header-->
			<div class="widget-body">
				<div class="widget-main no-padding">

					<div class="flip-scroll">
						<div class="dataTables_wrapper form-inline no-footer">
							<table class="table table-bordered table-striped table-condensed flip-content">
								<thead class="flip-content bordered-palegreen">
									<tr>
										<th>Code</th>
										<th>Name</th>
										<th>数值</th>
										<th></th>
										<th></th>
									</tr>
								</thead>
								<tbody>
									<% @dicts.each do |dict| %>
									<tr>
										<td><%= dict.code %></td>
										<td><%= dict.name %></td>
										<td>
										<ul class="dd-list">
											<% dict.dict_values.each do |v| %>
											<li class="dd-item bordered-blue">
												<span><%= v.value %></span>
											</li>
											<% end %>

										</ul></td>
										<td><!-- Button trigger modal -->
										<button type="button" value="<%= dict.id%>" data-id="<%= dict.id%>" class="btn btn-blue btn-xs modal-trigger" data-toggle="modal" data-target="#exampleModal">
											<i class="fa fa-plus"></i>添加
										</button></td>
										<td> <%= link_to image_tag('edit.gif'), edit_dict_path(dict) %>
										<%= link_to image_tag('trash.gif'), dict, method: :delete, data: { confirm: 'Are you sure?' } %></td>
									</tr>
									<% end %>
								</tbody>
							</table>
							<div class="row DTTTFooter">
								<div class="col-xs-12 col-md-12">
									<div class="dataTables_paginate paging_bootstrap" id="simpledatatable_paginate">
										<%= paginate @dicts, window: 1, outer_window: 1, remote: true %>
									</div>
								</div>
							</div>

						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
	<div class="modal-dialog modal-dialog-centered" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<h5 class="modal-title" id="exampleModalLabel">添加</h5>
			</div>
			<%= simple_form_for(@dict_value) do |f| %>
			<div class="modal-body">

				<%= f.error_notification %>
				<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

				<div class="form-inputs">
					<%= f.input :value, label: "数值" %>
				</div>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary btn-xs" data-dismiss="modal">
					取消
				</button>
				<%= f.button :submit,"提交", class: "btn btn-blue btn-xs" %>

			</div>
			<% end %>
		</div>
	</div>
</div>